home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 002a / zzt.zip / LANGTUT.HLP < prev    next >
Text File  |  1990-01-26  |  3KB  |  92 lines

  1. $ZZT-OOP
  2. $Programming Language Tutorial
  3.  
  4.    The best way to learn something is to
  5. jump right in, so let's not waste any
  6. time:
  7.  
  8.    To put an object on the board,  press
  9. F2 O.  After picking a character to
  10. represent the object,  you can enter a
  11. program to control it.
  12.  
  13. $Here is an example program
  14.  
  15.  Commands    Comments
  16.  ----------  ---------------------------
  17.  
  18.  @BadGuy     ' We are giving this object
  19.              '    the name "BadGuy".
  20.  /s/s/s      ' Start out by moving south
  21.              '    three times.
  22.  #shoot n    ' Next, shoot north.
  23.  #end        ' Now stop and wait for us
  24.              '    to receive a message.
  25.  :shot       ' When we receive a "SHOT"
  26.              '    message, start doing
  27.              '    the following commands.
  28.  #shoot seek ' Shoot towards the player.
  29.  #end        ' Stop and wait for another
  30.              '    message.
  31.  :touch      ' Do the following when we
  32.              '    receive a "TOUCH" msg.
  33.  Ouch! Stop touching me.
  34.              ' Put the preceeding text
  35.              '    on the screen.
  36.  #send shot  ' Next, send ourselves the
  37.              '    message "SHOT".
  38.  
  39.    Note that the "SHOT" message will be
  40. sent to BadGuy whenever the player shoots
  41. BadGuy.  Likewise, when the player touches
  42. BadGuy, BadGuy will receive the "TOUCH"
  43. message.
  44.  
  45.    ZZT-OOP is a relatively simple language
  46. and its commands are straightforward.
  47.  
  48.    The primary difference between ZZT-OOP
  49. and conventional languages such as BASIC
  50. is the use of messages.
  51.  
  52.    The following two objects illustrate
  53. a more intense use of messages:
  54.  
  55. $Here is the first object:
  56.  
  57.  @Lefty            ' This object's name.
  58.  /e/e/e/e          ' Move east 4 times.
  59.  /w/w/w/w          ' Then west 4 times.
  60.  #send Righty:Do   ' Send the "Do" message
  61.                    '   to the object named
  62.                    '   "Righty".
  63.  #end              ' And halt.
  64.  
  65. $Here is the other object:
  66.  
  67.  @Righty           ' This is our name.
  68.  #end              ' Don't do anything
  69.                    '    until we receive
  70.                    '    a message.
  71.  :do               ' Here's the "Do" msg.
  72.  /w/w/w/w          ' Move west 4 times.
  73.  /e/e/e/e          ' Then east 4 times.
  74.  #send lefty:restart'Tell our counterpart
  75.                    '    to restart.
  76.  #end              ' Done for now.
  77.  
  78.    These two objects form a feedback loop.
  79. When the game starts, Lefty will move
  80. then send a message to Righty.  This
  81. causes Righty to move then tell Lefty to
  82. restart.  So lefty moves, etc, etc, etc.
  83.  
  84. $- - -
  85.  
  86.    So concludes this mini-tutorial.  Once
  87. you think you have a grasp of the idea of
  88. ZZT-OOP programs and messages, you are
  89. ready to proceed to...
  90.  
  91. !-langref;The ZZT-OOP reference manual.
  92.